#include "StdAfx.h"
#include "RPG.h"

Graphics * gGraphics;

RPG::RPG(HINSTANCE hInst) : App(hInst)
{
	strcpy_s(className, "RPG Game FTW");
	strcpy_s(frameCaption, "RPG Game FTW");
	gGraphics = 0;
	gd3dDevice = 0;
}

RPG::~RPG(void)
{
	Shutdown();

	delete gGraphics;
}


int RPG::Init()
{
	gGraphics = new Graphics(hInst, hWND, D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);
	
	gGraphics->SetMode(hWND, true, true, 15, 15, 32);

	//camera.Point(2000.0000f, 0.0000f, -1000.0f, 0.0f, 0.0f, 0.0f);
	camera.Move(100.0f, 0.0f, -1000);
	gGraphics->SetCamera(&camera);

	testTexture.Load(gGraphics, "alienship.bmp");
	//gGraphics->EnableAlphaTesting(TRUE);
	gGraphics->EnableAlphaBlending(TRUE);
	//gGraphics->EnableZBuffer(TRUE);


	return true;
}

int RPG::Shutdown()
{
	gGraphics->Shutdown();

	return true;
}

int RPG::Frame()
{

	gGraphics->Clear(D3DCOLOR_ARGB(255,0,255,0)); 

	camera.Update();
	//gGraphics->GetDeviceCOM()->SetRenderState(D3DRS_ALPHATESTENABLE, true);
	if(gGraphics->BeginScene())
	{
		if(gGraphics->BeginSprite())
		{
			gGraphics->EnableAlphaTesting();
			testTexture.Blit(0,0, 0, 0, 0, 0, 1.0f, 1.0f, 3.14159f);
			gGraphics->EnableAlphaTesting(false);
			gGraphics->EndSprite();
		}

		gGraphics->EndScene();
		gGraphics->Draw();
	}
	
	return 0;
}